package com.springcloud.alibabanacosconfig.mq.component;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * @version V1.0
 * @Author 宋聚智
 * @Date 2019/10/22 16:54
 * @description  发送邮件消息模型
 * @Modify By：
 * @ModifyTime： 2019/10/22
 * @Modify marker：
 **/
@Configuration
public class MailConfig {
    @Autowired
    Environment env;
    @Bean
    public Queue mailQueue(){
        return  new Queue(env.getProperty("mail.queue.name"),true);
    }
    @Bean
    public DirectExchange mailExchange(){
        return new DirectExchange(env.getProperty("mail.exchange.name"),true,false);
    }
    @Bean
    public Binding mailBinder(){
        return BindingBuilder.bind(mailQueue()).to(mailExchange()).with(env.getProperty("mail.routing.key.name"));
    }

}
